﻿using System;
using TSU.FAMC.ComputerEngineering.Classes.Enums;

namespace TSU.FAMC.ComputerEngineering.Classes.Circuits.Basis
{
    /// <summary>
    /// Produces gate object by it's type.
    /// </summary>
    static public class GateFactory
    {
        /// <summary>
        /// Instanciates gate object by it's type.
        /// </summary>
        /// <param name="gateType">Gate type.</param>
        /// <returns>Gate object of corresponding type.</returns>
        static public Gate Create(GateType gateType)
        {
            if (gateType == GateType.Undefined)
            {
                // undefined type, creating stub
                return new StubGate();
            }

            if (gateType == GateType.Constant0)
            {
                return new Constant0Gate();
            }

            if (gateType == GateType.Constant1)
            {
                return new Constant1Gate();
            }

            if (gateType == GateType.Not)
            {
                return new NotGate();
            }

            if (gateType == GateType.And)
            {
                return new AndGate();
            }

            if (gateType == GateType.Or)
            {
                return new OrGate();
            }

            if (gateType == GateType.Nand)
            {
                return new NAndGate();
            }

            if (gateType == GateType.Nor)
            {
                return new NOrGate();
            }

            if (gateType == GateType.Dff)
            {
                return new Dff();
            }


            throw new NotImplementedException();
        }
    }
}
